#ifndef GFS_GLOBAL_H
#define GFS_GLOBAL_H

int CHUNKS; // FOR TESTING PURPOSE - originaly on gfsServices.h

#include <stdarg.h>
#include <pthread.h>
#include <globus_ftp_client.h>

/////////////////////////////////////////// MAX LENGTH ////////////////////////////////////////////
#define MAX_NAME 256
#define MAX_PATH 512
#define MAX_DATE 30
#define MAX_MODE 3

/////////////////////////////////////////// GFS SYSTEM ////////////////////////////////////////////

// DATA TYPE
#define GFS_size long long int
#define GFS_offset long long int

// DEBUGING
int VERBOSE;
extern void verbose(char *, ...);

// SUCCESS
#define GFS_SUCCESS 1
#define GFS_FAILED 0

// ERRORS
#define ECONN -1
#define ERNS -2
#define EFNOTVALID -11
#define EFEXIST -12
#define EDNOTVALID -21
#define EDEXIST -22
#define EDNOTEMPTY -23
#define EFDNOTVALID -31
#define EPERMIT -41
#define ELOCK -42

/////////////////////////////////////////// DESCRIPTOR ////////////////////////////////////////////
// GFS ITEM LINKED LIST
//linked list declaration, self referential
typedef struct GFS_itemD
{
	char item_name[MAX_NAME];
	char created_date[MAX_DATE];
	char modified_date[MAX_DATE];
	char type[1];
	GFS_size size;
	char owner[128];
	char permission[10];
	struct GFS_itemD *next;
} GFS_itemD;
//synonim declaration
typedef GFS_itemD *GFS_item;

// GFS SERVER LINKED LIST
//linked list declaration, self referential
typedef struct GFS_serverD
{
	char hostname[MAX_NAME];
	GFS_size total;
	GFS_size used;
	GFS_size unused;
	int rtt;
	char online[16];
	int online_status;
	int check_host_completed;
	int completed;
	struct GFS_serverD *next;
} GFS_serverD;
//synonim declaration
typedef GFS_serverD *GFS_server;

// GFS PHYSICAL LOCATION LINKED LIST
//linked list declaration, self referential
typedef struct GFS_physical_pathD
{
	char url[MAX_PATH];	
/*
	globus_ftp_client_handle_t 	handle;	
	globus_mutex_t 			lock;
	globus_cond_t 			cond;
	globus_bool_t 			done;
*/
	pthread_t 			thread;
	struct GFS_physical_pathD 	*next;
} GFS_physical_pathD;
//synonim declaration
typedef GFS_physical_pathD *GFS_physical_path;

// GFS FILE DESCRIPTOR
typedef struct GFS_fileD
{
	int 				file_id;
	GFS_offset			offset;
	GFS_size			file_size;
	char 				mode[MAX_MODE];	
	char 				file_name[MAX_NAME];	
	char				logical_loc[MAX_PATH];
	GFS_physical_path	physical_path;
	int 				pid;
	int 				process_status;
} GFS_fileD;
//synonim declaration
typedef GFS_fileD *GFS_file;

// GFS DIRECTORY DESCRIPTOR
typedef struct GFS_dirD
{
	int				dir_id;
	char 				mode[MAX_MODE];	
	char 				dir_name[MAX_NAME];	
	char				logical_loc[MAX_PATH];
	int 				pid;
	int 				process_status;
} GFS_dirD;
//synonim declaration
typedef GFS_dirD *GFS_dir;

#endif /* GFS_GLOBAL_H */
